package niuke;

import java.util.*;

public class 幸运的袋子 {

    static int n;
    static int[] numbers;
    static int result = 0;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        numbers = new int[n];
        for(int i = 0;i<n;i++){
            numbers[i] = scanner.nextInt();
        }
        Arrays.sort(numbers);
        bfs(0,new ArrayList<Integer>());
        System.out.println(result);
    }

    public  static boolean bfs(int k,List<Integer> list){
        List<Integer> list2 = new ArrayList<>();
        List<Integer> list3 = new ArrayList<>();
        for(int x:list){
            list2.add(x);
            list3.add(x);
            System.out.print(x+" ");
        }
        System.out.println();

        int judge = judge(list);
        int k2=k;
        if(judge == 1){
            result++;
        }
        else if(judge == -1){
            return false;
        }
        if(k >= numbers.length){
            return false;
        }
        list.add(numbers[k]);  //放入链表
        boolean re = bfs(k+1,list);      //取当前数

        list.remove(list.size()-1);  //取出当前数

        if (re == false) {    //表示不可以继续向下取的时候
            return true;
        }
        else {              //表示可以向下取   要取下一个不同的数
            for(int i=k;i<numbers.length;i++){
                if(numbers[i] != numbers[k2]){
                    k2 = i;
                    list.add(numbers[i]);
                    re = bfs(i+1,list);
                    if(re == false){
                        list.remove(list.size()-1);
                        break;
                    }
                    list.remove(list.size()-1);
                }
            }
            return true;
        }

    }

    public static int judge(List<Integer> list){
        long sum = 0;
        long mult = 1;
        if(list.size() == 0){
            return 2;
        }
        for(int x:list){
            sum = sum + x;
            mult = mult * x;
        }
        if(sum>mult){
            return 1;
        }
        else if(sum == mult){
            return 0;
        }
        else{
            return -1;
        }
    }
}
